package com.example.as.Mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.as.entity.ChatMessage;
import com.example.as.entity.Record;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.sql.Date;
import java.sql.Timestamp;
import java.util.List;

@Repository
@Mapper
public interface RecordMapper extends BaseMapper<Record> {
    @Insert("INSERT INTO record VALUES (NULL,#{time_stamp},#{sender},#{receiver},#{message},#{message_type})")
    int addRecord(Timestamp time_stamp, String sender, String receiver, String message, int message_type);

    @Select("SELECT * FROM record WHERE record.time_stamp > #{time_stamp}")
    List<ChatMessage> getHistoryList(Timestamp time_stamp);


    @Select("SELECT * FROM record")
    List<ChatMessage> getAllHistoryList();
}
